package com.smcaiot.jfttask.north.remote;

import com.smcaiot.core.gateway.north.Resources;
import com.smcaiot.core.gateway.north.RestResp;
import com.smcaiot.core.stereotype.Remote;
import com.smcaiot.core.stereotype.RemoteType;
import com.smcaiot.jfttask.north.local.TaskAppService;
import com.smcaiot.jfttask.north.message.AddTaskRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: cz
 * @Date: 2023/9/26
 * @Description:
 */
@RestController
@RequestMapping("/jftTaskSetting")
@Remote(RemoteType.Controller)
public class TaskController {

    @Autowired
    private TaskAppService taskAppService;

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public RestResp<?> addTask(@RequestBody AddTaskRequest addTaskRequest, @RequestHeader("userId") String userId) {
        addTaskRequest.setUserId(userId);
        return RestResp.execute(() -> taskAppService.addTask(addTaskRequest));
    }

}
